<style scoped>
  .ErrorRecord{
    margin-right: 15px;
    padding: 0 15px;
    background-color: white;
    height: 94.5vh;
    position: relative;
  }
  .err-top{
    display: flex;
    padding: 15px 0 15px 0;
    border-bottom: 1px solid #f4f4f4;
  }
  .err-top p:first-child{
    margin: 3px 6px 0 0;
    display: inline-block;
    white-space:nowrap;
  }
  .err-top p:not(:first-child){
    margin: 3px 6px 0 12px;
    display: inline-block;
    white-space:nowrap;
  }
  .inp{
    width: 160px;
  }
  .btn{
    padding: 15px;
  }
  .record{
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    /* border: 1px solid black; */
    background: white;
    width: 1200px;
    height: 500px;
    z-index: 10;
  }
  .record div:first-child{
    display: flex;
    justify-content: space-between;
    font-weight: 700;
    padding: 15px;
    background: #f4f4f4;
    margin-bottom: 10px;
  }
  .mask{
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    opacity: 0.3;
    z-index: 9;
  }
</style>
<style>
  .ErrorRecord .err-top .el-input__inner{
    height: 30px;
  }
  .ErrorRecord .err-top .el-date-editor .el-range-separator{
    width: 8%;
    line-height: 24px;
  }
  .ErrorRecord .err-top .el-date-editor .el-range__icon{
    line-height: 24px;
  }
  .ErrorRecord .err-top .el-checkbox.is-bordered{
    padding: 4px 20px 0 10px;
    height: 30px;
    margin-left: 15px;
  }
</style>
<template>
  <div class="ErrorRecord">
    <div class="mask" :style="{display:showBox}"></div>
    <div class="err-top">
      <p>日期</p>
      <el-date-picker
          unlink-panels
          style="width:300px;"
          v-model="timeDate"
          type="daterange"
          value-format="yyyy-MM-dd" format="yyyy-MM-dd"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期">
        </el-date-picker>

        <!-- <p>是否差异</p> -->
        <el-checkbox v-model="isDifference" border>是否差异</el-checkbox>
    </div>
    <div class="btn">
      <el-button @click="search" icon="el-icon-search" type="primary">查询</el-button>
    </div>
    <el-table
      :data="tableData"
      height="68vh"
      :header-cell-style="{background:'#f4f4f4',padding:0,height:'40px'}"
      :cell-style="{padding:0,height:'36px'}"
      highlight-current-row
      @row-dblclick="dbClick"
      style="width: 100%">
      <el-table-column
        prop="checkTime"
        label="核对日期">
      </el-table-column>
      <el-table-column
        prop="operator"
        label="操作员">
      </el-table-column>
      <el-table-column
        prop="softwareCustomerId"
        label="软件客户ID">
      </el-table-column>
      <el-table-column
        prop="isDifference"
        label="是否差异">
      </el-table-column>
    </el-table>

    <div class="record" :style="{display:showBox}">
      <div>
        <p>错误库存记录表</p>
        <i class="el-icon-close" @click="()=>{this.showBox='none'}"></i>
      </div>
      <el-table
        :data="tableData1"
        height="370px"
        :header-cell-style="{background:'#f4f4f4',padding:0,height:'40px'}"
        :cell-style="{padding:0,height:'36px'}"
        highlight-current-row
        style="width: 100%">
        <el-table-column
          prop="manufacturerNo"
          label="厂商编号">
        </el-table-column>
        <el-table-column
          prop="customerNo"
          label="客户编号">
        </el-table-column>
        <el-table-column
          prop="softwareCustomerId"
          label="软件客户ID"
          width="110">
        </el-table-column>
        <el-table-column
          prop="kindsNumber"
          label="货号"
          width="110">
        </el-table-column>
        <el-table-column
          prop="manufacturerInput"
          label="厂进数">
        </el-table-column>
        <el-table-column
          prop="manufacturerOut"
          label="厂退数">
        </el-table-column>
        <el-table-column
          prop="customerInput"
          label="客进数">
        </el-table-column>
        <el-table-column
          prop="customerSell"
          label="客销数">
        </el-table-column>
        <el-table-column
          prop="foldNumber"
          label="调入">
        </el-table-column>
        <el-table-column
          prop="calloutNumber"
          label="调出">
        </el-table-column>
        <el-table-column
          prop="differNumber"
          label="盘差">
        </el-table-column>
        <el-table-column
          prop="type"
          label="类型">
        </el-table-column>
        <el-table-column
          prop="enteringTime"
          label="记录时间"
          width="160">
        </el-table-column>
      </el-table>
      <div style="text-align:end;padding:10px;">
        <el-button @click="()=>{this.showBox='none'}">取消</el-button>
      </div>
    </div>

  </div>
</template>
<script>
import today from '../../../components/mixins/today'
import {getErrRecord,getErrRecordID} from '../../../network/errRecord'
import { warrant } from '../../../network/operatoryCommand'
export default {
  mixins:[today],
  created(){
    this.timeDate = [this.getLastWeek1(),this.getNowTime1()]
  },
  data(){
    return{
      timeDate:'',
      tableData:[],
      tableData1:[],
      showBox:'none',
      isDifference:false,
    }
  },
  methods:{
    search(){
      let obj = {
        startCheckTime:this.timeDate[0] + ' 00:00:00',
        endCheckTime:this.timeDate[1] + ' 23:59:59',
        isDifference:this.isDifference ? 1 : 0
      }
      // console.log(obj)
      getErrRecord(obj).then(res=>{
        this.tableData = res.data.data
      })
      // this.showBox = 'block'
    },
    dbClick(e){
      for(let i of [e]){
        if(i.isDifference == 0){
          this.$message({
            type:'warning',
            offset:400,
            message:'此数据无差异'
          })
        }else if(i.isDifference == 1){
          // let obj1 = {
          //   enteringTime:i.checkTime,softwareCustomerId:i.softwareCustomerId
          // }
          // console.log(obj1)
          getErrRecordID({enteringTime:i.checkTime,softwareCustomerId:i.softwareCustomerId}).then(res=>{
            // console.log(res.data)
            if(res.data.code == 200){
              this.tableData1 = res.data.data
            }else{
              this.$message.error({
              offset:400,
              message:'查询失败'
            })
            }
          })
          this.showBox = 'block'
        }
      }
    }
  }
}
</script>